package emulator.unittest.hardware.memory;

import static org.junit.Assert.assertEquals;

import org.junit.Test;

import emulator.hardware.memory.SparseMemory;
import emulator.hardware.memory.UnmappedMemoryException;
import emulator.hardware.memory.UnmappedMemoryThrow;

public class SparseMemoryTest {
	@Test
	public void testReadInitialized() throws UnmappedMemoryException
	{
		SparseMemory memory = new SparseMemory();
		memory.setUnmappedHandler(new UnmappedMemoryFail());
		
		memory.write(345, 17);
		assertEquals(17, memory.read(345));
	}
	
	@Test(expected= UnmappedMemoryException.class)
	public void testReadUninitialized() throws UnmappedMemoryException
	{
		SparseMemory memory = new SparseMemory();
		memory.setUnmappedHandler(new UnmappedMemoryThrow());
		
		assertEquals(17, memory.read(345));
	}
	
}
